<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">

    <title>物料分类</title>
    <link href="../lib/fonts/material-icons.css?family=Material+Icons" rel="stylesheet">
    <link href="../lib/css/animate.min.css" rel="stylesheet">
    <link href="../lib/css/quasar.mat.rtl.min.css" rel="stylesheet" type="text/css">

    <style type="text/css">
      [v-cloak] { display: none }
      .bd-light { border: 1px solid rgba(0, 0, 0, .1) }
      div.q-if-inner div.q-input-target {line-height: 24px}  /* 兼容 ie 的 */
    </style>
  </head>
  <body>
    <div id="q-meterialClassify" v-cloak>
      <q-card class="bg-white no-shadow full-width">
        <q-card-main class="relative-position">
          <q-tabs 
            v-model="selectedTab" 
            color="primary"
            inverted 
            @select="getTreeData">
            <q-tab 
              style="width:100px" 
              v-for="(item, index) in tabData" 
              :default="index == 0? true: false" 
              slot="title" 
              icon="merge_type"
              :name="item.value" 
              :label="item.label"></q-tab>
          </q-tabs>
          <q-fab
            color="primary"
            class="absolute"
            style="right:18px; bottom:-5px"
            icon="keyboard_arrow_down"
            direction="down"
          >
            <q-fab-action
              color="primary"
              @click="openAddTabModal"
              icon="add"
            ></q-fab-action>
            <q-fab-action
              color="secondary"
              @click="openEditTabModal"
              icon="edit"
            ></q-fab-action>
            <q-fab-action
              color="negative"
              @click="deleteTabComfirm"
              icon="delete"
            ></q-fab-action>
          </q-fab>
        </q-card-main>
      </q-card>
      <q-card class="bg-white no-shadow full-width" v-if="tabData.length > 0">
        <q-card-main class="row justify-start gutter-sm">
          <q-card class="col-lg-3 col-md-4 col-sm-4 col-xs-12 no-shadow">
            <q-card-main class="q-pa-sm q-mt-xs q-mr-sm relative-position">
              <q-inner-loading :visible="visible">
                <q-spinner-gears size="50px" color="primary"></q-spinner-gears>
              </q-inner-loading>
              <q-search v-model="searchNodes"></q-search>
              <q-tree
                class="q-mt-md tree-styl"
                color="secondary"
                :nodes="meterialLevelData"
                node-key="value"
                :filter="searchNodes"
                no-results-label="没有找到结果"
                :expanded.sync="expandedNodes"
                :selected.sync="nodeSelected"
                tickable
                tick-strategy="leaf"
                :ticked.sync="nodeTicked"
              >
                <!-- 节点插槽 -->
                <div slot="header-right" slot-scope="prop">
                  {{ prop.node.label }}
                  <q-context-menu>
                      <div class="q-pa-xs" v-if="!prop.node.isRoot">
                        <q-btn
                          flat
                          v-close-overlay
                          color="primary"
                          size="sm"
                          @click="openAddLevelModal(prop.node, 4)"
                        >
                          <span>{{ $t("新增父级") }}</span>
                        </q-btn>
                      </div>
                      <div class="q-pa-xs">
                        <q-btn
                          flat
                          v-close-overlay
                          color="primary"
                          size="sm"
                          @click="openAddLevelModal(prop.node, 3)"
                        >
                          <span>新增下级</span>
                        </q-btn>
                      </div>
                      <div class="q-pa-xs" v-if="!prop.node.isRoot">
                        <q-btn
                          flat
                          v-close-overlay
                          color="primary"
                          size="sm"
                          @click="openAddLevelModal(prop.node, 2)"
                        >
                          <span>新增上级</span>
                        </q-btn>
                      </div>
                      <div class="q-pa-xs" v-if="!prop.node.isRoot">
                        <q-btn
                          flat
                          v-close-overlay
                          color="primary"
                          size="sm"
                          @click="openAddLevelModal(prop.node, 1)"
                        >
                          <span>新增平级</span>
                        </q-btn>
                      </div>
                      <div class="q-pa-xs" v-if="!prop.node.isRoot">
                        <q-btn
                          color="secondary"
                          flat
                          v-close-overlay
                          size="sm"
                          @click="openEditLevelModal(prop.node)"
                        >
                          <span>编辑</span>
                        </q-btn>
                      </div>
                      <div class="q-pa-xs" v-if="!prop.node.isRoot">
                        <q-btn
                          flat
                          v-close-overlay
                          color="negative"
                          size="sm"
                          @click="deleteNodeComfirm(prop.node)"
                        >
                          <span>删除</span>
                        </q-btn>
                      </div>
                  </q-context-menu>
                </div>
              </q-tree>
            </q-card-main>
          </q-card>
          <!-- 右侧 -->
          <!-- <q-card class="col-lg-9 col-md-8 col-sm-8 col-xs-12 no-shadow">
            <q-card-main class="q-pa-sm q-mt-xs q-mr-sm relative-position">
              <div class="row justify-start gutter-sm q-px-sm">
                <q-field class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
                  <q-input
                    :float-label="$t('供应商名称')"
                    v-model="searchForm.name"></q-input>
                </q-field>
              </div>
              <div class="row justify-end q-my-sm">
                <q-btn
                  size="sm"
                  @click="getTableData({pagination: serverPagination, nodeSelected: nodeSelected})"
                  color="primary"
                  class="q-mt-sm q-mr-sm q-pa-sm">
                  <q-icon name="search"></q-icon>
                  <span>{{ $t('查询') }}</span>
                </q-btn>
                <q-btn
                  size="sm"
                  color="secondary"
                  @click="reset"
                  class="q-mt-sm q-mr-sm q-pa-sm">
                  <q-icon name="refresh" ></q-icon>
                  <span>{{ $t('重置') }}</span>
                </q-btn>
                <q-btn
                  flat
                  size="sm"
                  class="q-mt-sm q-mr-xs q-pa-sm"
                  color="primary"
                  @click="isShowMoreSearch = !isShowMoreSearch">
                  <span v-if="isShowMoreSearch">{{ $t('收起') }}</span>
                  <span v-else>{{ $t('展开') }}</span>
                  <q-icon v-if="isShowMoreSearch" name="keyboard arrow up" ></q-icon>
                  <q-icon v-else name="keyboard arrow down" ></q-icon>
                </q-btn>
              </div>
              <q-table
                class="no-shadow"
                :data="tableData"
                dense
                :columns="allColumns"
                :visible-columns="allVisibleColumns"
                :rows-per-page-options="[5, 10, 20]"
                selection="multiple"
                :loading = "listLoading"
                :selected.sync="selected"
                :pagination.sync="serverPagination"
                @request="getTableData"
                row-key="id"
              >
                <template slot="top-right" slot-scope="props">
                  <q-table-columns
                    style="width:66px"
                    color="secondary"
                    class="q-mr-sm"
                    :label="$t('展示项')"
                    v-model="allVisibleColumns"
                    :columns="allColumns"
                  ></q-table-columns>
                  <q-btn
                    flat round dense
                    :icon="props.inFullscreen ? 'fullscreen_exit' : 'fullscreen'"
                    @click="props.toggleFullscreen"
                  ></q-btn>
                </template>
                <template slot="top-left" slot-scope="props">
                  <q-btn
                    color="secondary"
                    flat
                    @click="goSupplierInvite"
                    :label="$t('邀请')"
                    class="q-mr-sm" ></q-btn>
                  <q-btn
                    color="secondary"
                    flat
                    @click="openAddModal"
                    :label="$t('新增')"
                    class="q-mr-sm" ></q-btn>
                  <q-btn
                    color="negative"
                    flat
                    @click="supplierRestrict"
                    :label="$t('限制')"
                    class="q-mr-sm" ></q-btn>
                  <q-btn
                    color="negative"
                    flat
                    :label="$t('删除')"
                    @click="deleteComfirm"></q-btn>
                </template>
                <div slot="pagination" slot-scope="props" class="row flex-center q-py-sm">
                  第
                  <q-pagination
                    v-model="serverPagination.page"
                    input
                    boundary-links
                    direction-links
                    color="secondary"
                    :max-pages="5"
                    :ellipses="true"
                    :max="pages"></q-pagination>
                  页 &nbsp; 共 {{ total }} 条
                </div>
                <template slot="body" slot-scope="props">
                  <q-tr
                    :props="props"
                  >
                    <q-td >
                      <q-checkbox color="primary" v-model="props.selected"></q-checkbox>
                    </q-td>
                    <q-td key="action" :props="props" >
                      <q-btn
                        flat
                        round
                        size="xs"
                        @click="openEditModal(props.row)"
                        color="secondary"
                      >
                        <q-icon name="edit" size="16px"></q-icon>
                      </q-btn>
                      <q-btn
                        flat
                        round
                        size="xs"
                        @click="deleteRowComfirm(props.row)"
                        color="negative"
                        >
                        <q-icon name="delete" size="16px"></q-icon>
                      </q-btn>
                    </q-td>
                    <q-td
                      key="vendorName"
                      :props="props">{{ props.row.vendorName }}</q-td>
                    <q-td
                      key="invitationStatus"
                      :props="props">
                      <q-chip small square color="positive">{{ invitationStatusToText(props.row.invitationStatus) }}</q-chip>
                    </q-td>
                    <q-td
                      key="vendorEmail"
                      :props="props">{{ props.row.vendorEmail }}</q-td>
                    <q-td
                      key="contactPeople"
                      :props="props">{{ props.row.contactPeople }}</q-td>
                    <q-td
                      key="contactTelephone"
                      :props="props">{{ props.row.contactTelephone }}</q-td>
                    <q-td
                      key="createTime"
                      :props="props">{{ props.row.createTime }}</q-td>
                    <q-td
                      key="lastUpdateTime"
                      :props="props">{{ props.row.lastUpdateTime }}</q-td>
                    <q-td
                      key="dataSources"
                      :props="props">{{ props.row.dataSources }}</q-td>
                  </q-tr>
                </template>
              </q-table>
            </q-card-main>
          </q-card> -->
        </q-card-main>
      </q-card>
      <!-- tab modal -->
      <q-modal no-backdrop-dismiss v-model="tabAddOrEditModal" :content-css="{minWidth: '66vw', minHeight: '550px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              {{ addOrEdit === 0 ? $t("新增") : $t("编辑")  }}
            </q-toolbar-title>
            <q-btn flat @click="tabAddOrEditModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="q-px-md q-py-sm bg-white no-shadow full-width">
            <q-card-main class="row gutter-x-md gutter-y-sm">
              <q-field 
                :error="$v.tabAddOrEditForm.name.$error"
                error-label="名称不能为空"
                class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                <q-input
                  :float-label="$t('名称')"
                  @blur="$v.tabAddOrEditForm.name.$touch"
                  v-model="tabAddOrEditForm.name"></q-input>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              flat
              color="primary"
              @click="tabAddOrEditModal = false">{{$t("取消")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              v-if="addOrEdit === 0"
              @click="saveAddTabHandler">{{$t("保存")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              v-else
              @click="saveEditTabHandler">{{$t("保存")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
      <!-- tree add modal -->
      <q-modal no-backdrop-dismiss v-model="nodeAddModal" :content-css="{minWidth: '66vw', minHeight: '550px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              {{ addOrEdit === 0 ? $t("新增") : $t("编辑")  }}
            </q-toolbar-title>
            <q-btn flat @click="nodeAddModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="q-px-md q-py-sm bg-white no-shadow full-width">
            <q-card-main class="row gutter-x-md gutter-y-sm">
              <q-field 
                :error="$v.nodeAddForm.name.$error"
                error-label="名称不能为空"
                class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <q-input
                  :float-label="$t('名称')"
                  @blur="$v.nodeAddForm.name.$touch"
                  v-model="nodeAddForm.name"></q-input>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              flat
              color="primary"
              @click="nodeAddModal = false">{{$t("取消")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              v-if="addOrEdit === 0"
              @click="saveAddNodeHandler">{{$t("保存")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              v-else
              @click="saveEditNodeHandler">{{$t("保存")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
      <!-- tree edit modal -->
      <q-modal no-backdrop-dismiss v-model="nodeEditModal" :content-css="{minWidth: '66vw', minHeight: '550px',borderRadius: '4px'}">
        <q-modal-layout>
          <q-toolbar slot="header" color="white">
            <q-toolbar-title class="text-dark">
              {{ addOrEdit === 0 ? $t("新增") : $t("编辑")  }}
            </q-toolbar-title>
            <q-btn flat @click="nodeEditModal = false">
              <q-icon name="close" color="dark"></q-icon>
            </q-btn>
          </q-toolbar>
          <q-card class="q-px-md q-py-sm bg-white no-shadow full-width">
            <q-card-main class="row gutter-x-md gutter-y-sm">
              <q-field 
                :error="$v.nodeEditForm.name.$error"
                error-label="名称不能为空"
                class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <q-input
                  :float-label="$t('名称')"
                  @blur="$v.nodeEditForm.name.$touch"
                  v-model="nodeEditForm.name"></q-input>
              </q-field>
              <q-field 
                v-if="addOrEdit == 1"
                :error="$v.nodeEditForm.arraynumber.$error"
                :error-label="$v.nodeEditForm.arraynumber.required? ($v.nodeEditForm.arraynumber.mustNumber? '': '必须为数字'): '不能为空'"
                class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <q-input
                  :float-label="$t('排序')"
                  @blur="$v.nodeEditForm.arraynumber.$touch"
                  v-model="nodeEditForm.arraynumber"></q-input>
              </q-field>
            </q-card-main>
          </q-card>
          <q-toolbar slot="footer" color="white" class="row justify-end">
            <q-btn
              flat
              color="primary"
              @click="nodeEditModal = false">{{$t("取消")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              v-if="addOrEdit === 0"
              @click="saveAddNodeHandler">{{$t("保存")}}</q-btn>
            <q-btn
              flat
              :loading="btnLoading"
              color="primary"
              v-else
              @click="saveEditNodeHandler">{{$t("保存")}}</q-btn>
          </q-toolbar>
        </q-modal-layout>
      </q-modal>
    </div>
    <!-- ie-polyfill 、 vue.js and quasar-framework -->
    <script src="../lib/js/quasar.ie.polyfills.umd.min.js"></script>
    <script src="../lib/js/vue.js"></script>
    <script src="../lib/js/quasar.mat.umd.min.js"></script>
    <!-- babel for es6 transform -->
    <!-- <script src="lib/js/babel.min.js"></script> -->
    <!-- vue validate -->
    <script src="../lib/js/vuelidate.min.js"></script>
    <script src="../lib/js/validators.min.js"></script>
    <!-- consts ps: always leave this file first -->
    <script src="../script/consts.js"></script>
    <!-- status code -->
    <script src="../script/status.code.js"></script>
    <!-- qs for axios -->
    <script src="../lib/js/qs.min.js"></script>
    <!-- axios for http request -->
    <script src="../lib/js/axios.js"></script>
    <!-- axios.instance must be after axios -->
    <script src="../script/axios.instance.js"></script>
    <!-- quasar i18n zh-hans -->
    <script src="../lib/lang/zh-hans.js"></script>
    <!-- vue-i18n for application's internationalization -->
    <script src="../lib/js/vue-i18n.js"></script>
    <!-- current page international file -->
    <script src="../lang/sop/meterialClassify.js"></script>

    <script>
      // quasar components i18n
      Quasar.i18n.set(Quasar.i18n[LANGUGE])

      Vue.use(window.vuelidate.default)
      var minLength = window.validators.minLength
      var helpers = window.validators.helpers
      var required = window.validators.required
      var email = window.validators.email
      var mustNumber = function(value) {
        return /^[0-9]+$/.test(value) || !helpers.req(value)
      }

      var meterialClassify = new Vue({
        el: '#q-meterialClassify',
        i18n: i18n,
        data: function() {
          return {
            btnLoading: false,
            addOrEdit: 0,
            // tab
            selectedTab: '1',
            tabData: [],
            tabAddOrEditModal: false,
            tabAddOrEditForm: {
              name: ''
            },
            // tree
            addLevel: '', // 新增哪一级
            searchNodes: '', // 查询节点
            visible: false, // tree loading
            meterialLevelData: [
              {
                label : "全部分类",
                value : "0",
                header : "right",
                children : []
              }
            ], // 树的节点数据
            expandedNodes: ['0'], // 展开的节点
            nodeSelected: [], // 当前左键单击的节点
            nodeTicked: [], // 勾选的节点
            currentNodeId: '', // 当前右键点击的节点
            nodeAddModal: false,
            nodeEditModal: false,
            nodeAddForm: {
              name: ''
            },
            nodeEditForm: {
              name: '',
              arraynumber: ''
            }
            // table
            // isShowMoreSearch: false,
            // searchForm: {
            //   name: ''
            // },
            // tableData: [], // 表格数据
            // listLoading: false, // 表格loading
            // selected: [], // 勾选的行
            // total: 0, // 总条数  
            // serverPagination: { // 分页
            //   page: 1,
            //   rowsNumber: 5,
            //   rowsPerPage: 5
            // },
            // allVisibleColumns: [ // 可见的列
            //   'action',
            //   'vendorName',
            //   'invitationStatus',
            //   'vendorEmail',
            //   'contactPeople',
            //   'contactTelephone',
            //   'createTime',
            //   'lastUpdateTime',
            //   'dataSources'
            // ],
          }
        },
        validations: {
          tabAddOrEditForm: {
            name: { required: required }
          },
          nodeAddForm: {
            name: { required: required }
          },
          nodeEditForm: {
            name: { required: required },
            arraynumber: { required: required, mustNumber: mustNumber }
          }
        },
        computed: {
          // 表格配置
          // allColumns: function() {
          //   return []
          // },
          // pages: function() {
          //   return Math.ceil(this.total / this.serverPagination.rowsPerPage)
          // }
        },
        watch: {
          nodeSelected: function(nodeSelected) {
            // this.getTabData({
            //   pagination: this.serverPagination,
            //   nodeSelected: nodeSelected
            // })
          }
        },
        created: function() {
          this.getTabData()
        },
        methods: {
          // Tab 的
          getTabData: function() {
            var that = this
            axios({
              method: 'post',
              url: '/manager/new/classifyTypeName/queryAll',
            })
            .then(function(data) {
              if (data.statusCode == 200) {
                that.tabData = data.rows
              } else {
                that.$q.notify({
                  message: that.$t(STATUS_CODE[data.statusCode]),
                  icon: 'error_outline',
                  type: 'negative',
                  position: 'top-right'
                })
              }
            })
            .catch(function(err) {

            })
          },
          openAddTabModal: function() {
            this.tabAddOrEditModal = true
            this.tabAddOrEditForm = {
              name: ''
            }
            this.$v.tabAddOrEditForm.$reset()
            this.addOrEdit = 0
          },
          openEditTabModal: function () {
            var that = this
            axios({
              method: 'post',
              url: '/manager/new/classifyTypeName/findClassifyTypeName',
              data: {
                id: this.selectedTab
              }
            })
            .then(function(data) {
              if (data.statusCode == 200) {
                that.addOrEdit = 1
                that.tabAddOrEditForm = {
                  name: data.single.name
                }
                that.tabAddOrEditModal = true
              } else {
                that.$q.notify({
                  message: that.$t(STATUS_CODE[data.statusCode]),
                  icon: 'error_outline',
                  type: 'negative',
                  position: 'top-right'
                })
              }
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          saveAddTabHandler: function () {
            this.$v.tabAddOrEditForm.$touch()
            if (!this.$v.tabAddOrEditForm.$error) {
              this.btnLoading = true
              var that = this
              axios({
                method: 'post',
                url: '/manager/new/classifyTypeName/addclassifyTypeList',
                data: {
                  name: this.tabAddOrEditForm.name,
                  type: 1
                }
              })
              .then(function(data) {
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: that.$t('新增成功'),
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                that.tabAddOrEditModal = false
                that.getTabData()
              })
              .catch(function(err) {
                console.log(err)
              })
            }
          },
          saveEditTabHandler: function () {
            this.$v.tabAddOrEditForm.$touch()
            if (!this.$v.tabAddOrEditForm.$error) {
              var that = this
              this.btnLoading = true
              axios({
                method: 'post',
                url: '/manager/new/classifyTypeName/updateClassifyType',
                data: {
                  id: this.selectedTab,
                  name: this.tabAddOrEditForm.name,
                  type: 1
                }
              })
              .then(function(data) {
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: '编辑成功',
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                that.tabAddOrEditModal = false
                that.getTabData()
              })
              .catch(function(err) {
                console.log(err)
              })
            }
          },
          deleteTabComfirm: function() {
            var that = this
            this.$q.dialog({
              title: this.$t('确认')+'？',
              message: this.$t('您确定要删除当前Tab吗')+'？',
              ok: {
                label: this.$t('确认'),
                flat: true
              },
              cancel: {
                label: this.$t('取消'),
                flat: true
              }
            })
            .then(function() {
              axios({
                method: 'post',
                url: '/manager/new/classifyTypeName/deleteclassifyTypeList',
                data: {
                  ids: that.selectedTab,
                  type: 1
                }
              })
              .then(function(data) {
                console.log(data)
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: '删除成功',
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                  that.getTabData()
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
              })
              .catch(function(err) {

              })
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          // 节点的
          getTreeData: function(tab) {
            this.visible = true
            var that = this
            axios({
              method: 'post',
              url: '/manager/new/classifyCustom/tree2/' + tab + '/1'
            })
            .then(function(data) {
              if (data.statusCode == 200) {
                that.meterialLevelData[0].children = data.rows
                var _arr = []
                that.meterialLevelData.map(function(item) {
                  item.isRoot = true
                  _arr.push(item)
                })
                that.meterialLevelData = _arr
              } else {
                that.$q.notify({
                  message: that.$t(STATUS_CODE[data.statusCode]),
                  icon: 'error_outline',
                  type: 'negative',
                  position: 'top-right'
                })
              }
              that.visible = false
            })
            .catch(function(err) {

            })
          },
          openAddLevelModal: function(currentLevel, addLevel) {
            console.log(currentLevel)
            this.nodeAddForm = {
              name: ''
            }
            this.$v.nodeAddForm.$reset()
            this.addOrEdit = 0
            this.nodeAddModal = true
            this.currentNodeId = currentLevel.value
            this.addLevel = addLevel
          },
          saveAddNodeHandler: function() {
            this.$v.nodeAddForm.$touch()
            if (!this.$v.nodeAddForm.$error) {
              this.btnLoading = true
              var that = this
              axios({
                method: 'post',
                url: '/manager/new/classifyCustom/addClassifyCustom',
                data: {
                  id: this.currentNodeId,
                  currentlyId: this.currentNodeId, 
                  currentlyType: this.addLevel,
                  type: 1,
                  typeNameId: this.selectedTab,  // 当前tab
                  name: this.nodeAddForm.name
                }
              })
              .then(function(data) {
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: that.$t('新增成功'),
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                that.nodeAddModal = false
                that.getTreeData(that.selectedTab)
              })
              .catch(function(err) {

              })
            }
          },
          openEditLevelModal: function(currentLevel) {
            this.currentNodeId = currentLevel.value
            var that = this
            this.addOrEdit = 1
            axios({
              method: 'post',
              url: '/manager/new/classifyCustom/byId',
              data: {
                id: currentLevel.value
              }
            })
            .then(function(data) {
              if (data.statusCode == 200) {
                that.nodeEditForm = {
                  name: data.single.name,
                  arraynumber: data.single.arraynumber
                }
                that.nodeEditModal = true
              } else {
                that.$q.notify({
                  message: that.$t(STATUS_CODE[data.statusCode]),
                  icon: 'error_outline',
                  type: 'negative',
                  position: 'top-right'
                })
              }
            })
            .catch(function(err) {
              console.log(err)
            })
          },
          saveEditNodeHandler: function() {
            this.$v.nodeEditForm.$touch()
            if (!this.$v.nodeEditForm.$error) {
              this.btnLoading = true
              var that = this
              axios({
                method: 'post',
                url: '/manager/new/classifyCustom/updateClassifyCustom',
                data: {
                  id: this.currentNodeId,
                  name: this.nodeEditForm.name,
                  arraynumber: this.nodeEditForm.arraynumber
                }
              })
              .then(function(data) {
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: that.$t('修改成功'),
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
                that.btnLoading = false
                that.nodeEditModal = false
                that.getTreeData(that.selectedTab)
              })
              .catch(function(err) {

              })
            }
          },
          deleteNodeComfirm: function(currentLevel) {
            var that = this
            this.$q.dialog({
              title: this.$t('确认')+'？',
              message: this.$t('您确定要删除该节点吗')+'？',
              ok: {
                label: this.$t('确认'),
                flat: true
              },
              cancel: {
                label: this.$t('取消'),
                flat: true
              }
            })
            .then(function() {
              axios({
                method: 'post',
                url: '/manager/new/classifyCustom/deleteClassifyCustom',
                data: {
                  ids: currentLevel.value,
                  type: 1
                }
              })
              .then(function(data) {
                if (data.statusCode == 200) {
                  that.$q.notify({
                    message: '删除成功!',
                    icon: 'done',
                    type: 'positive',
                    position: 'top-right'
                  })
                } else {
                  that.$q.notify({
                    message: that.$t(STATUS_CODE[data.statusCode]),
                    icon: 'error_outline',
                    type: 'negative',
                    position: 'top-right'
                  })
                }
                that.getTreeData(that.selectedTab)
              })
              .catch(function(err) {
                console.log(err)
              })
            })
            .catch(function() {
              // 选择"Cancel"或作了关闭操作
            })
          },
          // 表格的
          // getTableData: function(arg) {
          //   this.listLoading = true
          //   this.serverPagination = arg.pagination
          //   var that = this
          //   axios({
          //     method: 'post',
          //     url: '',
          //     data: {
          //       nodeSelected: arg.nodeSelected,
          //       page: this.serverPagination.page,
          //       rows: this.serverPagination.rowsPerPage,
          //       sort: this.serverPagination.sortBy,
          //       order: this.serverPagination.descending == true? 'desc' : (this.serverPagination.descending == false? 'asc' : ''),
          //       search_LIKE_name: this.searchForm.name
          //     }
          //   })
          //   .then(function(data) {
          //     that.tableData = data.rows
          //     that.total = data.total
          //     that.listLoading = false
          //   })
          //   .catch(function(err) {
          //     console.log(err)
          //   })
          // },
          // reset: function() {

          // },
        }
      })
    </script>
  </body>
</html>